package org.jeecg.modules.system.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.system.entity.yifen;
import org.jeecg.modules.system.service.impl.YifenServiceimlp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/yifen")
public class yifenController {

    @Autowired
    private YifenServiceimlp yifenService;
/*
        @RequestMapping("/list")
    public IPage<Map<String, Object>> selectMapsPage(IPage<yifen> page) {//IPage<yifen> page, @Param(Constants.WRAPPER) Wrapper<yifen> queryWrapper
        IPage<yifen> ipage  = new Page<>(1, 5);
        if(page.getSize()==0){
            page  = new Page<>(1, 5);
        }
        QueryWrapper<yifen> query = new QueryWrapper<>();
        return yifenService.selectMapsPage(page,query);
    }*/

    @RequestMapping(value = "/list")
    public Result<IPage<yifen>> queryPageList(yifen yifen, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                              @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) {
        Result<IPage<yifen>> result = new Result<IPage<yifen>>();
        QueryWrapper<yifen> queryWrapper = QueryGenerator.initQueryWrapper(yifen, req.getParameterMap());
        Page<yifen> p = new Page<yifen>(pageNo, pageSize);
        IPage<yifen> pageList = yifenService.page(p, queryWrapper);
        result.setSuccess(true);
        result.setResult(pageList);
        return result;
    }
}
